﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:Framework.UI.Controls"
                    xmlns:metro="http://schemas.codeplex.com/elysium"
                    xmlns:params="clr-namespace:Elysium.Parameters;assembly=Elysium">
    <ResourceDictionary.MergedDictionaries>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Converter.xaml"/>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Brush.xaml"/>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/ElysiumExtra/BorderFix.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="{x:Type metro:Submenu}" TargetType="{x:Type metro:Submenu}" >
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.DefaultThickness),Mode=OneWay}" />
        <Setter Property="params:MenuBase.SubmenuBackground" Value="{Binding RelativeSource={RelativeSource Self},Path=Background,Mode=OneWay}" />
        <Setter Property="params:MenuBase.SubmenuBorderBrush" Value="{Binding RelativeSource={RelativeSource Self},Path=BorderBrush,Mode=OneWay}" />
        <Setter Property="params:MenuBase.SubmenuBorderThickness" Value="{Binding RelativeSource={RelativeSource Self},Path=BorderThickness,Mode=OneWay}" />
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.ContentFontSize),Mode=OneWay}" />
        <Setter Property="FontStretch" Value="Medium" />
        <Setter Property="FontStyle" Value="Normal" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
        <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
        <Setter Property="params:General.ShadowBrush" Value="{StaticResource ForegroundBrush}" />
        <Setter Property="Grid.IsSharedSizeScope" Value="True" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalOnly" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.BoldPadding),Mode=OneWay}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type metro:Submenu}">
                    <controls:BorderFix x:Name="LayoutRoot" 
                            Tag="{DynamicResource {x:Static SystemParameters.DropShadowKey}}" 
                            Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}"
                            TextBlock.Foreground="{TemplateBinding Foreground}" 
                            TextBlock.FontSize="{TemplateBinding FontSize}" 
                            TextBlock.FontStretch="{TemplateBinding FontStretch}" 
                            TextBlock.FontStyle="{TemplateBinding FontStyle}" 
                            TextBlock.FontWeight="{TemplateBinding FontWeight}" 
                            TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" 
                            TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" 
                            RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" 
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle"/>
                    </controls:BorderFix>
                    <ControlTemplate.Triggers>
                        <DataTrigger Value="True" DataTrigger.Binding="{Binding ElementName=LayoutRoot,Path=Tag}">
                            <Setter TargetName="LayoutRoot" Property="UIElement.Effect">
                                <Setter.Value>
                                    <DropShadowEffect DropShadowEffect.BlurRadius="4" DropShadowEffect.ShadowDepth="2" DropShadowEffect.Direction="315" DropShadowEffect.Opacity="0.3" DropShadowEffect.Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type metro:Submenu}},Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}" />
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="LayoutRoot" Value="{StaticResource TransparentBrush}" Property="Border.Background" />
                            <Setter TargetName="LayoutRoot" Property="Border.Padding" Value="0,0,6,6" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger DataTrigger.Binding="{Binding RelativeSource={RelativeSource Self},Path=FontSize,Mode=OneWay,Converter={StaticResource IsGreaterThanConverter},ConverterParameter=18}">
                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="DropDownCommandButtonSubmenuStyle" TargetType="{x:Type metro:Submenu}" BasedOn="{StaticResource {x:Type metro:Submenu}}" >
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type metro:Submenu}">
                    <Border x:Name="LayoutRoot" FrameworkElement.Tag="{DynamicResource {x:Static SystemParameters.DropShadowKey}}">
                        <ScrollViewer Background="{TemplateBinding Background}" 
                                      BorderBrush="{TemplateBinding BorderBrush}" 
                                      BorderThickness="{TemplateBinding BorderThickness}"
                                      Foreground="{TemplateBinding Foreground}" 
                                      Control.FontFamily="{TemplateBinding Control.FontFamily}" 
                                      FontSize="{TemplateBinding FontSize}" 
                                      FontStretch="{TemplateBinding FontStretch}" 
                                      FontStyle="{TemplateBinding FontStyle}" 
                                      FontWeight="{TemplateBinding FontWeight}" 
                                      TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" 
                                      TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" 
                                      RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" 
                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                            <FrameworkElement.Resources>
                                <ResourceDictionary>
                                    <Style TargetType="{x:Type ScrollBar}" BasedOn="{StaticResource {x:Type ScrollBar}}">
                                        <Style.Triggers>
                                            <Trigger Property="ScrollBar.Orientation" Value="Vertical">
                                                <Setter Property="BorderThickness" Value="0" />
                                            </Trigger>
                                        </Style.Triggers>
                                    </Style>
                                </ResourceDictionary>
                            </FrameworkElement.Resources>
                            <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle"/>
                        </ScrollViewer>
                    </Border>
                    <ControlTemplate.Triggers>
                        <DataTrigger Value="True" DataTrigger.Binding="{Binding ElementName=LayoutRoot,Path=Tag}">
                            <Setter TargetName="LayoutRoot" Property="UIElement.Effect">
                                <Setter.Value>
                                    <DropShadowEffect DropShadowEffect.BlurRadius="4" DropShadowEffect.ShadowDepth="0" DropShadowEffect.Direction="90" DropShadowEffect.Opacity="0.7" DropShadowEffect.Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type metro:Submenu}},Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}" />
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="LayoutRoot" Value="{StaticResource TransparentBrush}" Property="Border.Background" />
                            <Setter TargetName="LayoutRoot" Property="Border.Padding" Value="4" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>